﻿using System;
using System.Globalization;
using System.Windows.Data;
using GpgApi;

namespace WgpgGUI
{
    [ValueConversion(typeof(KeyTrust), typeof(String))]
    public sealed class TrustToStringConverter : IValueConverter
    {
        public String Full { get; set; }
        public String Marginal { get; set; }
        public String None { get; set; }
        public String Ultimate { get; set; }
        public String Minimum { get; set; }
        public String Invalid { get; set; }
        public String Revoked { get; set; }
        public String Expired { get; set; }

        public Object Convert(Object value, Type targetType, Object parameter, CultureInfo culture)
        {
            KeyTrust trust = (KeyTrust)value;

            switch (trust)
            {
                case KeyTrust.Ultimate:
                    return Ultimate;
                case KeyTrust.Full:
                    return Full;
                case KeyTrust.Marginal:
                    return Marginal;
                case KeyTrust.Minimum:
                    return Minimum;
                case KeyTrust.Invalid:
                    return Invalid;
                case KeyTrust.Revoked:
                    return Revoked;
                case KeyTrust.Expired:
                    return Expired;
                case KeyTrust.None:
                case KeyTrust.Undefined:
                case KeyTrust.Unknown:
                    return None;
                default:
                    return String.Empty;
            }
        }

        public Object ConvertBack(Object value, Type targetType, Object parameter, CultureInfo culture)
        {
            throw new NotSupportedException();
        }
    }
}
